<template>
  <el-container class="main">
    <el-aside width="200px">
      <el-scrollbar>
        <el-menu :default-openeds="['2']">
          <el-sub-menu index="1">
            <template #title>
              <el-icon><Odometer /></el-icon>我的任务
            </template>
            <el-menu-item-group>
              <el-menu-item index="1-1">代办任务</el-menu-item>
              <el-menu-item index="1-2">已办任务</el-menu-item>
            </el-menu-item-group>
          </el-sub-menu>
          <el-sub-menu index="2">
            <template #title>
              <el-icon><Notebook /></el-icon>工艺技术协调单
            </template>
            <el-menu-item-group>
              <el-menu-item index="2-1" :class="{'is-active': curPath=='/main/xjxtd'}">
                <router-link to="/main/xjxtd">新建协调单</router-link>
            </el-menu-item>
              <el-menu-item index="2-2" :class="{'is-active': curPath=='/main/xtdlb'}">
                <router-link to="/main/xtdlb">查询与导出</router-link>
              </el-menu-item>
            </el-menu-item-group>
          </el-sub-menu>
          <el-sub-menu index="3">
            <template #title>
              <el-icon><Calendar /></el-icon>权限配置管理
            </template>
            <el-menu-item-group>
              <el-menu-item index="3-1">角色权限配置</el-menu-item>
            </el-menu-item-group>
          </el-sub-menu>
        </el-menu>
      </el-scrollbar>
    </el-aside>

    <el-container style="min-width: 800px;">
      <el-header>
        <h2 class="title">COMAC飞机制造管理系统</h2>
        <div class="toolbar">
          <span>当前用户：{{ adminStore.adminName }}</span>
          <el-dropdown>
            <el-icon style="margin-left: 8px; margin-top: 1px" color="#fff">
              <setting />
            </el-icon>
            <template #dropdown>
              <el-dropdown-menu>
                <el-dropdown-item>管理员信息</el-dropdown-item>
                <el-dropdown-item>更多管理员</el-dropdown-item>
                <el-dropdown-item>退出登录</el-dropdown-item>
              </el-dropdown-menu>
            </template>
          </el-dropdown>
        </div>
      </el-header>

      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script lang="ts" setup>
import { ref, provide } from 'vue'
import { Calendar, Odometer, Notebook, Setting } from '@element-plus/icons-vue'
import { useAdminStore } from '../store/admin'

const adminStore = useAdminStore()
const curPath = ref('/main/xtdlb')
const setCurPath = (path)=>{
    curPath.value = path
}
provide('setCurPath', setCurPath)
</script>

<style scoped>
.main {
    width: 100vw;
    height: 100vh;
}
.main .el-header {
  position: relative;
  background-color: var(--cc-theme-color-blue);
  color: #fff;
}
.main .el-aside {
  color: #fff;
  background: var(--cc-theme-color-blue);
  padding: 10px;
}
.main .el-menu {
  border-right: none;
}
.main .el-menu-item.is-active {
  background-color: var(--el-menu-hover-bg-color);
}
.main .el-main {
  padding: 10px;
}
.main .el-header {
    display: flex;
    flex-direction: row;
    align-items: center;
}
.main .el-header  .title {
    flex: 1;
}
.main .toolbar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  right: 20px;
}
</style>